﻿/*
* 创建者：LIYINFAI
* 创建时间：2023/10/24 9:35:26
* 描述：
* --------------------------------------
* 修改说明：
* --------------------------------------
*/
using Newtonsoft.Json;
using System.Collections.Generic;
using System.ComponentModel;

namespace CommonLibrary
{
    /// <summary>
    /// bool类型标签所属的数组定义
    /// </summary>
    public class BoolTagBelong
    {
        /// <summary>
        /// 所属的数组名称
        /// </summary>
        public string Category { get; set; }
        /// <summary>
        /// 元素下标
        /// </summary>
        public int Index { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 描述信息
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return CommonHelper.GetObjectString(this);
        }
    }
    /// <summary>
    /// 出站类型
    /// </summary>
    public enum EOutType
    {
        /// <summary>
        /// 正常出站
        /// </summary>
        FINAL = 0,
        /// <summary>
        /// Hi-Pot出站
        /// </summary>
        HIPOT = 1
    }
    /// <summary>
    /// PLC数据设定
    /// </summary>
    public class PLCTagSetting
    {
        /// <summary>
        /// 对应的生产数据实体中的属性名称
        /// </summary>
        [Description("实体属性")]
        [JsonProperty(PropertyName = "ormName")]
        public string ORMName { get; set; }
        /// <summary>
        /// PLC地址或标签值
        /// </summary>
        [Description("PLC地址")]
        [JsonProperty(PropertyName = "tag")]
        public string Tag { get; set; }
        /// <summary>
        /// 数据类型（string, short, float, decimal, long8time, longtime, int 可以扩充其他)
        /// </summary>
        [Description("数据类型")]
        [JsonProperty(PropertyName = "typeName")]
        public string TypeName { get; set; }
        /// <summary>
        /// 长度，数据类型为string时有效
        /// </summary>
        [Description("数据长度")]
        [JsonProperty(PropertyName = "len")]
        public int len { get; set; } = 0;
        /// <summary>
        /// 除值，将PLC读到的值乘以该值
        /// </summary>
        [JsonProperty(PropertyName = "div")]
        public float div { get; set; } = 1.0f;
        /// <summary>
        /// 表示是否将PLC所读的值转换为Float类型
        /// </summary>
        [JsonProperty(PropertyName = "isToFloat")]
        public bool IsToFloat { get; set; } = false;
        /// <summary>
        /// 描述信息
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return CommonHelper.GetObjectString(this);
        }
    }

    /// <summary>
    /// 一个出站信号多组电芯出站
    /// </summary>
    public class MultiPLCTagParameter
    {
        /// <summary>
        /// 出站类型，0 - 产品出站，其他值可扩展
        /// </summary>
        [JsonProperty(PropertyName = "outType")]
        public EOutType OutType { get; set; } = EOutType.FINAL;
        /// <summary>
        /// 备注信息
        /// </summary>
        [JsonProperty(PropertyName = "remark")]
        public string Remark { get; set; }
        /// <summary>
        /// 触发地址
        /// </summary>
        [JsonProperty(PropertyName = "triggerAddress")]
        public string TriggerAddress { get; set; }
        /// <summary>
        /// 出站PLC标签或地址内容
        /// </summary>
        [JsonProperty(PropertyName = "multiTagSettings")]
        public List<List<PLCTagSetting>> Parameters { get; set; } = new List<List<PLCTagSetting>>();
        /// <summary>
        /// 出站结果地址
        /// </summary>
        [JsonProperty(PropertyName = "resultAddress")]
        public string ResultAddress { get; set; }
        /// <summary>
        /// 出站完成地址
        /// </summary>
        [JsonProperty(PropertyName = "doneAddress")]
        public string DoneAddress { get; set; }
        /// <summary>
        /// 描述信息
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return CommonHelper.GetObjectString(this);
        }
    }
}
